/*-------Print At home -----*/ var strPrintAtHome = "false"; var currentTab = 0; showTab(currentTab); function showTab(n) { var x = document.getElementsByClassName("modal-tab"); x[n].style.display = "block"; if (n == 0) { document.getElementById("prevBtn").style.display = "none"; document.getElementById("prevBtn2").style.display = "none"; } else { document.getElementById("prevBtn").style.display = "inline"; document.getElementById("prevBtn2").style.display = "inline"; } if (n == 2) { document.getElementById("nextBtn").innerHTML = confirmBtnText; document.getElementById("nextBtn2").innerHTML = confirmBtnText; } else { document.getElementById("nextBtn").innerHTML = nextBtnText; document.getElementById("nextBtn2").innerHTML = nextBtnText; } } function nextPrev(n) { var x = document.getElementsByClassName("modal-tab"); var strCurrentTab = currentTab; currentTab = currentTab + n; var validated = true; switch (currentTab) { case 2: if (!$("#rbDWhoPerson").prop('checked') && !$("#rbDWhoSomeone").prop('checked')) { alert(MsgPleaseSelectOneSend); validated = false; currentTab = currentTab - n; return; } if (!$("#tbSendCardEmail").val()) { alert(MsgPleaseEnterMail); validated = false; currentTab = currentTab - n; return; } //var re = /^\w+([-+.'][^\s]\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*$/; var re = /^(([^<>()[\]\.,;:\s@\"]+(\.[^<>()[\]\.,;:\s@\"]+)*)|(\".+\"))@(([^<>()[\]\.,;:\s@\"]+\.)+[^<>()[\]\.,;:\s@\"]{2,})$/i; var emailFormat = re.test($("#tbSendCardEmail").val());// this return result in boolean type if (!emailFormat) { alert(MsgPleaseEnterValidEmail); validated = false; currentTab = currentTab - n; return; } if ($("#rbDWhoSomeone").prop('checked')) { if (!$("#tbDWhoSomeone").val()) { alert(MsgRecepientNameNotBlank); validated = false; currentTab = currentTab - n; return; } } break; case 1: /*if (!$("#tbFirstName").val()) { alert(MsgEnterHonorsFullName); validated = false; currentTab = currentTab - n; return; } */ if (!$("#tbDWhoSomeone").val()) { alert(MsgRecepientNameNotBlank); validated = false; currentTab = currentTab - n; return; } if (!$("#tbDWhoSomeone").val()) { alert(MsgRecepientNameNotBlank); validated = false; currentTab = currentTab - n; return; } if ($("#ddDedication").val() == "-1" || $("#ddDedication").val() == "") { alert(MsgSelectDedication); validated = false; currentTab = currentTab - n; return; } break; } if (!validated) return; x[currentTab - n].style.display = "none"; //currentTab = currentTab + n; if (currentTab == 2) { preViewEcard() } if (currentTab > x.length - 1) { currentTab = currentTab - 1; //location.reload(); //alert('last tab') SaveECardDedication() } if (strPrintAtHome == "true") { strCurrentTab + '' + currentTab; if (currentTab == 2) { currentTab = currentTab + n; } } if ($('#tbDWhoSomeone').val() != '') { $('#lblsendTo').html(msgSendToName.replace('{name}', $('#tbDWhoSomeone').val())); if ($("#rbDWhoPerson").prop('checked')) { $('#whatwillSendTo').html(msgwhatWillSentTo.replace('{name}', $('#tbDWhoSomeone').val())); } else { $('#whatwillSendTo').html(msgwhatWillSentTo.replace('{name}', $('#tbFirstName').val())); } } showTab(currentTab); } $("#linkGivehonorSomeone").on('click', function () { $("#iho").modal(); if ($('#rbDWhoSomeone').is(':checked')) { $('#modal-radio-2').click(); } $('#ddDedication').change(); }); $('#mdlPrintAtHome').click(function () { strPrintAtHome = "true"; }); /*-----------end Print At home--------------------*/ $(document).ready(function () { /*---------active price btn----------*/ var priceStr = $('#defaultSelect').text(); var monthlyPriceStr = $('#defaultMonthlySelect').text(); $('#btn-selected a').click(function () { $('a').removeClass("selected"); $(this).addClass("selected"); priceStr = $(this).text(); }); $('#monthly-btn-selected a').click(function () { $('a').removeClass("selected"); $(this).addClass("selected"); monthlyPriceStr = $(this).text(); }); /*--------modal radio show/hide-----------*/ $('#modal-radio').click(function () { if (!$('#modal-radio').hasClass('disable')) { $('.recipientFullName').hide(); $("#rbDWhoPerson").prop('checked', true); $("#rbDWhoSomeone").prop('checked', false); } else { $("#rbDWhoPerson").prop('checked', false); } }); $('#modal-radio-2').click(function () { $('.recipientFullName').show(); $("#rbDWhoPerson").prop('checked', false); $("#rbDWhoSomeone").prop('checked', true); }); /*----------------Send Email Card------------ */ $('#active-btn .type').click(function () { $('.type').removeClass("active"); $(this).addClass("active"); }); /*---------------Price Donate tabs--------------- */ $(".price-donate").click(function () { $('.other-btn').show(); $('.otherBtn-text').css("display", "none"); }); $(".monthly-price-donate").click(function () { $('#monthlyOtherBtn').show(); $('#monthlyOtherBtnText').css("display", "none"); }); /*--------------- Show the next step of credit card on button click if there are no validation messages -------*/ /*--------Tabs Show/hide-------*/ $("#donate-btn").on('click', function () { $("#pills-card").show(); $("#pills-home").hide(); if ($("#pills-home-tab").hasClass("active")) { $('#once-op').show(); $('#monthly-op').hide(); $('#monthly-amount').hide(); $('#yearly-amount').hide(); $('#amount-once').show(); if (priceStr == 'Other Amount') { priceStr = '$' + $("#txtinptOthrAmt").val(); } $('.selAmt').text(priceStr); } if ($("#pills-home-tab1").hasClass("active")) { $('#once-op').hide(); $('#monthly-op').show(); $('#amount-once').hide(); $('#monthly-amount').show(); $('#yearly-amount').hide(); if (priceStr == 'Other Amount') { monthlyPriceStr = '$' + $("#txtinptOthrAmt").val() + "/mo"; } $('.selMonthlyAmt').text(monthlyPriceStr); } }); $('.home').click(function () { $("#txtinptOthrAmt").val(''); $('#amount-once').show(); $('#monthly-amount').hide(); $('#yearly-amount').hide(); // $('#btn-selected').show(); $('.spnPerMonth').hide(); //$('#monthly-btn-selected').hide(); }); $('.monthly').click(function () { $("#txtinptOthrAmt").val(''); $('#amount-once').hide(); $('#monthly-amount').show(); $('#yearly-amount').hide(); //$('#btn-selected').hide(); $('.spnPerMonth').show(); //$('#monthly-btn-selected').show(); }); $("#pills-home-tab").on('click', function () { $('#btn-selected').show(); $('#btn-Monthlyselected').hide(); $("#pills-monthly").hide(); $("#pills-profile").hide(); $("#pills-card").hide(); $("#pills-home").show(); }); $("#pills-home-tab1").on('click', function () { $('#btn-selected').hide(); $('#btn-Monthlyselected').show(); ActiveMonthly(); }); $("#edit-pills-home-tab1").on('click', function () { ActiveMonthly(); }); $("#edit-pills-home-tab2").on('click', function () { ActiveMonthly(); }); function ActiveMonthly() { $("#pills-monthly").hide(); $("#pills-profile").hide(); $("#pills-card").hide(); $("#pills-home").show(); } /*-------popover i------------*/ $(function () { $('[data-toggle="popover"]').popover({ trigger: 'focus' }); }); $('#ddDedication').change(function () { if ($(this).val() == '2') { $('#rbDWhoSomeone').click(); $('#modal-radio').addClass('disable'); } else { $('#modal-radio').removeClass('disable'); } }); }); /*---------Other Amount btn-----*/ function otherAmountFun(ele) { var eid = '#' + ele.id; var etxt = '#' + ele.id + 'Text'; $(eid).hide(); $(etxt).css("display", "block"); $(etxt + " div input").focus(); } /*------------Credit Card-------*/ //var stripe = Stripe('pk_test_6pRNASCoBOKtIshFeQd4XMUh'); //var elements = stripe.elements(); //var style = { // base: { // padding: '10px 12px', // color: '#757575', // fontFamily: '-apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif', // fontSmoothing: 'antialiased', // fontSize: '1rem', // fontWeight: '300', // '::placeholder': { // color: '#757575', // fontWeight: '300' // }, // }, // invalid: { // color: '#fa755a', // } //}; //var card = elements.create('card', { // style: style //}); //card.mount('#card-element'); //card.addEventListener('change', function(event) { // var displayError = document.getElementById('card-errors'); // if (event.error) { // displayError.textContent = event.error.message; // } else { // displayError.textContent = ''; // } //}); //var form = document.getElementById('payment-form'); //form.addEventListener('submit', function(event) { // event.preventDefault(); // stripe.createToken(card).then(function(result) { // if (result.error) { // var errorElement = document.getElementById('card-errors'); // errorElement.textContent = result.error.message; // } else { // stripeTokenHandler(result.token); // } // }); //}); //function stripeTokenHandler(token) { // var form = document.getElementById('payment-form'); // var hiddenInput = document.createElement('input'); // hiddenInput.setAttribute('type', 'hidden'); // hiddenInput.setAttribute('name', 'stripeToken'); // hiddenInput.setAttribute('value', token.id); // form.appendChild(hiddenInput); // form.submit(); //} /*-----Language----*/ var style_cookie_name = "style"; var style_cookie_duration = 30; var style_domain = "israelgives.com"; function switch_style(css_title) { var i, link_tag; for (i = 0, link_tag = document.getElementsByTagName("link"); i < link_tag.length; i++) { if ((link_tag[i].rel.indexOf("stylesheet") != -1) && link_tag[i].title) { link_tag[i].disabled = true; if (link_tag[i].title == css_title) { link_tag[i].disabled = false; } } set_cookie(style_cookie_name, css_title, style_cookie_duration, style_domain); } } function set_style_from_cookie() { var css_title = get_cookie(style_cookie_name); if (css_title.length) { switch_style(css_title); } } function set_cookie(cookie_name, cookie_value, lifespan_in_days, valid_domain) { var domain_string = valid_domain ? ("; domain=" + valid_domain) : ''; document.cookie = cookie_name + "=" + encodeURIComponent(cookie_value) + "; max-age=" + 60 * 60 * 24 * lifespan_in_days + "; path=/" + domain_string; } function get_cookie(cookie_name) { var cookie_string = document.cookie; if (cookie_string.length != 0) { var cookie_array = cookie_string.split('; '); for (i = 0; i < cookie_array.length; i++) { cookie_value = cookie_array[i].match(cookie_name + '=(.*)'); if (cookie_value != null) { return decodeURIComponent(cookie_value[1]); } } } return ''; } //function to restrict text box for alphabets only function onlyAlphabets(textforValidation) { var HeAlphabetsArray = [1489, 64305, 1488, 1463, 1464, 1492, 1491, 1490, 1461, 1462, 1495, 1494, 1493, 64331, 1465, 64315, 1497, 1496, 64309, 1467, 1500, 1498, 1499, 1460, 1497, 1504, 1501, 1502, 1456, 1506, 1505, 1503, 1468, 1507, 1508, 64324, 1511, 1509, 1510, 64299, 64298, 1512, 1514, 64330, 1513]; if ((textforValidation.which > 96 && textforValidation.which < 123) || (textforValidation.which > 64 && textforValidation.which < 90) || textforValidation.which == 32 || (textforValidation.which > 128 && textforValidation.which < 255) || jQuery.inArray(textforValidation.which, HeAlphabetsArray) != -1) { return true; } else { return false; } } function NumbersOnly(e) { if (e.which != 8 && e.which != 0 && (e.which < 48 || e.which > 57)) { return false; } } function OnlyAphanumeric(e) { if ((e.which > 96 && e.which < 123) || (e.which > 64 && e.which < 90) || e.which == 32 || e.which == 8 || e.which == 0 || (e.which > 47 && e.which <= 57)) { return true; } else { return false; } } function checkTextAreaMaxLength(textBox, e, length) { var mLen = textBox["MaxLength"]; if (null == mLen) mLen = length; var maxLength = parseInt(mLen); if (!checkSpecialKeys(e)) { if (textBox.value.length > maxLength - 1) { if (window.event)//IE e.returnValue = false; else//Firefox e.preventDefault(); } } } function checkSpecialKeys(e) { if (e.keyCode != 8 && e.keyCode != 46 && e.keyCode != 37 && e.keyCode != 38 && e.keyCode != 39 && e.keyCode != 40) return false; else return true; } function SaveECardDedication() { //$('#hypSubmitECard').bind('click', function () { --validateECardForm() --selectdTribute != -1 && $('#ddlAkno').val() if (true) { $('#dvloadsendecard').show(); $(this).hide(); $('#hypPreviewECard').hide(); $('#hypEditECard').hide(); //send ajax req var urltoCall = '/custom/Handlers/SendECard.ashx'; var dedication = '0'; if ($('#rbDWhoSomeone').is(':checked')) { dedication = '1'; } dedication = $('#ddDedication option:selected').val(); var firstName = $('#tbFirstName').val(); if ($('#rbDWhoPerson').is(':checked')) { firstName = $('#tbDWhoSomeone').val(); } $.ajax({ url: urltoCall, global: false, type: "POST", dataType: "json", data: { title: $('.ddlTitle .jquery-selectbox-currentItem').html(), fname: firstName, lname: '', dedication: dedication, issomeone: $('#rbDWhoSomeone').is(':checked'), someonename: $('#tbDWhoSomeone').val(), personalmsg: $('#tbPersonalMsg').val(), isanonymous: $('#rbDonationFromAnonymous').is(':checked'), donationfrom: $('#tbDonationFrom').val(), ispostalmail: $('#rbSendCardPost').is(':checked'), sendtoemail: $('#tbSendCardEmail').val(), address: $('#tbAddress').val(), city: $('#tbCity').val(), cid: $("#ddlCountry option:selected").val(), sid: $("#ddlState option:selected").val(), zipcode: $('#tbZip').val(), lang: ecardLanguage, tribute: selectdTribute, generateTemplate: '0', route: routingName, amuta: _govId, donid: -1 }, async: true, success: function (res) { if (res.status != 'error') { $('#hdnIGUserParam').val(res.IGUserParam); //parent.ClosePopup(); //alert('succes'); $('.modal-close').click(); $('.linkGivehonorSomeone').html(SuccessTextForDidecation); } else { alert(res.msg); $('#dvloadsendecard').hide(); $('#hypSubmitECard').show(); $('#hypPreviewECard').show(); } }, error: function (err) { alert(err); $('#hypPreviewECard').show(); $('#dvloadsendecard').hide(); } }); } //}); } function ShoweCardCreationLink(todisplay) { if (todisplay) { $('.aftercreated').hide(); $('.beforecreated').show(); } else { $('.aftercreated').show(); $('.beforecreated').hide(); } } function preViewEcard() { $('#ecardpreview').html(msgLoadingPreview); var urltoCall = '/custom/Handlers/sendecard.ashx'; var dedication = '0'; if ($('#rbDWhoSomeone').is(':checked')) { dedication = '1'; } dedication = $('#ddDedication option:selected').val(); var firstName = $('#tbFirstName').val(); if ($('#rbDWhoPerson').is(':checked')) { firstName = $('#tbDWhoSomeone').val(); } $.ajax({ url: urltoCall, global: false, type: "POST", dataType: "json", data: { title: "", fname: firstName, lname: '', dedication: dedication, issomeone: $('#rbDWhoSomeone').is(':checked'), someonename: $('#tbDWhoSomeone').val(), personalmsg: $('#tbPersonalMsg').val(), isanonymous: $('#rbDonationFromAnonymous').is(':checked'), donationfrom: $('#tbDonationFrom').val(), ispostalmail: $('#rbSendCardPost').is(':checked'), sendtoemail: $('#tbSendCardEmail').val(), address: $('#tbAddress').val(), city: $('#tbCity').val(), cid: $("#ddlCountry option:selected").val(), sid: $('#hdnstate').val(), zipcode: $('#tbZip').val(), lang: ecardLanguage, tribute: selectdTribute, generateTemplate: '1', route: routingName, amuta: _govId, donid: -1 }, async: true, success: function (res) { if (res.status != 'error') { $('#hdnIGUserParam').val(res.IGUserParam); $(this).hide(); $('#hypEditECard').show(); $('#ecardpreview').html(res.msg);//.show(); $('#contentform').hide(); $('#hypPreviewECard').hide(); } else { alert(res.msg); } }, error: function (err) { $('#hypPreviewECard').show(); $('#dvloadsendecard').hide(); } }); }